package com.dog.service;

import com.dog.dao.DAO;
import com.dog.model.BaseEntity;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author <a href="mailto:sand_by@mail.ru">Andrew Sakhno</a> 26.04.2010
 */

/**
 * method naming conventions:
 * 1. search,getting,retrieve methods should starts with 'get' eg. getBySmth
 * 2. update methods should starts with 'update'
 * 3. delete methods should starts with 'delete'
 */
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public interface IBaseService<D extends DAO<E>, E extends BaseEntity> {

    D getDao();

    E get(Long id);

    E save(E entity);

    void update(E entity);

    void delete(E entity);

    int getTotalCount();

    List<E> getByRange(int start, int count, String field, boolean asc);

    List<E> getAll();
}
